{% include 'front/header1.html' %}
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.6&key=4cf311835bbf55ce280047af1fbd7c85&plugin=AMap.CitySearch"></script>
<link rel="stylesheet" href="/resource/front/css/mobile/quill.bubble.css" />
<link rel="stylesheet" href="/resource/front/css/mobile/quill.core.css" />
<link rel="stylesheet" href="/resource/front/css/mobile/quill.snow.css" />
<style type="text/css">
	body {}
	
	.mui-bar {
		background: #000000 !important;
		color: #fff !important;
		position: relative !important;
	}
	
	.mui-title {
		color: #fff !important;
	}
	
	#top-content img.lazy {
		width: 100%;
	}
	table{
		width: 100%;
	}
	
	.mui-bar {
		position: absolute;
	}
	
	.mui-bar .mui-title {
		left: 0;
		right: 0;
	}
	
	.left {
		text-align: left !important;
	}
	
	.right {
		text-align: center !important;
	}
	
	textarea,
	p {
		margin-bottom: 0;
	}
	
	#bottom-content {
		/*padding: 0 19px;*/
		display: flex;
	}
	
	#ly p {
		color: 0.32rem;
		color: #333;
	}
	
	.other {
		/*padding: 0 19px;*/
		width: 100%;
		display: flex;
		flex-flow: row;
		flex-wrap: wrap;
		justify-content: space-between;
	}
	
	.content {
		padding-top: 0px !important;
	}
	
	input {
		font-size: 0.32rem;
	}
	
	#submit {
		color: #fff;
	}
	
	.get-money {
		width: 7.733333rem;
		height: 608px;
		position: fixed;
		top: 246px;
		z-index: 1001;
		margin: auto;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
	}
	
	.alert-img-box {
		top: 150px;
		width: 100%;
		/*width: 3.293333rem;
		 height: 4.053333rem;*/
		position: relative;
	}
	
	.alert-img-box img {
		width: 95%;
		height: 100%;
		/*margin-left: 10%;*/
		object-fit: cover;
	}
	
	.alert-img-box .p {
		display: flex;
		flex-flow: column;
		justify-content: center;
		position: absolute;
		left: 0;
		top: 10px;
		right: 0;
		bottom: 1.173333rem;
	}
	
	.alert-img-box .p p {
		text-align: center;
		color: #fff;
		margin-bottom: .1rem;
		font-size: 0.35rem;
	}
	
	.top-tool {
		width: 100%;
		max-width: 600px;
		height: 1.76rem;
		background: #fff;
		margin: auto;
		position: fixed;
		top: 0;
		z-index: 1500;
	}
	
	.top-tool .ye,
	.top-tool .lb {
		width: 100%;
		height: 1.76rem;
		display: flex;
		flex-flow: row;
		padding: 0 0.666666rem 0 0.48rem;
		align-items: center;
		justify-content: space-between;
		z-index: 800;
	}
	
	.top-tool .lb,
	.top-tool .ye {
		position: fixed;
		top: 0;
		background: #fff;
	}
	
	.ye .my-pay-btn {
		width: 1.6rem;
		height: 0.666666rem;
		color: #fff;
		background: #00d4d2;
		border-radius: 0.08rem;
		text-align: center;
		line-height: 0.666666rem;
		font-size: 0.32rem;
	}
	
	.ye span,
	.lb span {
		font-size: 0.4rem;
	}
	
	.lb .get-money-btn {
		width: 1.6rem;
		height: 0.666666rem;
		color: #fff;
		background: #fe0154;
		border-radius: 0.08rem;
		text-align: center;
		line-height: 0.666666rem;
		font-size: 0.32rem;
	}
	
	.alert-con {
		width: 100%;
		position: absolute;
		top: 1.8rem;
		bottom: 0;
		left: 0;
		right: 0;
		margin: auto;
		z-index: 1040;
	}
	
	.alert-con h3 {
		text-align: center;
	}
	
	.get-money1 {
		width: 95%;
		top: 246px;
		z-index: 1001;
		margin: auto;
	}
	
	body {
		background: #fff !important;
	}
	
	.ql-editor {
		padding: 0 !important;
	}
	
	#phone {
		position: absolute;
		right: 0rem;
		z-index: 2000;
		z-index: 1500;
		cursor: pointer;
		display: none;
	}
	
	#phone img {
		width: 2.5rem;
	}
	
	.close {
		position: absolute;
		top: 0;
		right: 0;
		width: 29px !important;
		height: 29px !important;
		top: -12px !important;
		right: 4px !important;
	}
	
	.tel {
		width: ;
		position: fixed;
		top: 2.45rem;
		left: 0;
		right: 0;
		margin: auto;
		width: 5.213333rem;
		height: 130px;
		background: #fff;
		border-radius: 0.066666rem;
		font-size: 0.293333rem;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #00d4d2;
		z-index: 1501;
	}
	
	.close1 {
		width: 0.4rem;
		position: absolute;
		top: -0.186666rem;
		right: -0.186666rem;
	}
	
	.u-flyer {
		z-index: 2000;
	}
</style>
<script>
	function setFont() {
		var HTML = document.getElementsByTagName('html')[0];
		var Size = document.documentElement.clientWidth / 10;
		if(Size >= 102) {
			Size = 102
		}
		HTML.style.fontSize = Size + 'px';
		var body = document.getElementsByTagName('body')[0];
		body.style.margin = '0 auto';
		body.style.width = Size * 10 + 'px';
	};
	setFont(); //初始适配
	window.onresize = function() { //窗口大小改变适配
		setFont();
	};
</script>
<div class="" style="max-width: 600px; height: 100%; margin:0 auto ;position: relative;background: #fff !important;">
	<div class="content">
		<div class="top-tool">
			<div class="" id="islogin" style="display: none;">
				<div class="ye" style=";">
					<span id="" style="display: inline-block;">
						<span id="" style="margin-bottom: 0.266666rem;">
							我的余额：
						</span>
					<span style="color: #00d4d2;" id="user_earn">
							0LCB
						</span>
					</span>
					<div class="my-pay-btn">
						我的钱包
					</div>
				</div>
			</div>
			<div class="" id="nologin" style="display: none;">
				<div class="lb">
					<span id="">
						已有龙币：<span style="color: #00d4d2;" id="yylb">0LCB</span>
					</span>
					<div class="get-money-btn">
						立即领取
					</div>
				</div>
			</div>
			<div id="phone" type="tel">
				<a><img src="/resource/front/images/forward/phone_num.jpg" /></a>
			</div>
		</div>

		<div class="" style="padding:15px;position: relative;background: #f4f4f4;">
			<div id="" style="    width: 100%;max-width: 600px; background: transparent;margin: auto;position: fixed; top: 0;z-index: 1500;">
				<div id="phone" style="right: 15px;">
					<a><img src="/resource/front/images/forward/phone_num.jpg" /></a>
				</div>
			</div>
			<div id="top-content">
			</div>
			<div id="" class="" style="padding: .15rem .19rem;">

				<div id="bottom-content">

				</div>
				<div class="other" id="form" style="display: none;">
					<input field="name" required="true" errmsg="请输入姓名" style="margin-top: 0.213333rem; width:  45%;  padding-left: 5px;   font-size: 16px; border-color: #999; height: 0.16rem; " placeholder="姓名" type="text" class="mui-input-password" data-input-password="3">
					<input field="tel" required="true" errmsg="请输入电话" style="margin-top: 0.213333rem;  width:  45%; padding-left: 5px;border-color: #999;     font-size: 16px;height: 0.16rem;" type="number" placeholder="电话" class="mui-input-password" data-input-password="3">
					<textarea field="content" required="true" errmsg="请输入备注" style="width: 100%; height: 1.866666rem;font-size: 0.16rem;     font-size: 16px; border-color: #999; " name="" rows="" cols="" placeholder="备注"></textarea>
					<input type="button" id="submit" value="提交" style="margin-top: 19px;width: 100%;background-color: #3f81f7;border-color: #3f81f7;border-radius: 2px;">
				</div>
			</div>
			<div class="js_dialog" style="opacity: 1;display: none;">
				<div class="weui-mask"></div>
			</div>

			<!--<img id="qrcode" class="longtap" src="/resource/front/images/forward/money.png" />-->
			<div class="get-money" style="opacity: 1; display: none;">
				<div class=" alert-img-box">
					<div id="">
						<img src="/resource/front/images/forward/money.png" />
					</div>
					<div class="p">
						<p>恭喜您</p>
						<p>您得到<span id="lcb"></span>个LCB奖励</p>
						<p style="margin-bottom: 0rem; font-size: 0.35rem;">快来领取吧！</p>
					</div>
				</div>
			</div>

			<div class="telbox" style="display: none;z-index: 1501;">
				<div class="tel">
					<img class="close1" src="/resource/front/images/forward/delete.png" style="" />
					<span id="tel">
						
					</span>
				</div>
			</div>
		</div>
	</div>
</div>
{% include 'front/foot.html' %}
<script type="text/javascript" src="/resource/front/css/mobile/jquery.fly.min.js"></script>
<script type="text/javascript" src="/resource/front/css/mobile/jquery.lazyload.min.js"></script>
<script>
	var local = window.location.href;
	var isIos = false;
	if(local.indexOf('&ios') > 0) {
		isIos = true;
		local = local.split('&ios')[0];
	}
	var ad_id = (local.split('suiyi_id=')[1]).split("?")[0];
	var suiyi1 = local.split('suiyi1=')[1];
	suiyi1 = suiyi1.split('&suiyi2=')[0]; //token
	var suiyi2 = local.split('&suiyi2=')[1];
	suiyi2 = (parseInt(suiyi2.split('&suiyi3')[0] * 1000) / (5.19 * 1000)) - 2.8; //uid
	var suiyi3 = local.split('&suiyi3=')[1]; //ucode
	mui.ready(function() {
		$('.content').css('min-height',document.documentElement.clientHeight);
		mui.init({
			gestureConfig: {
				longtap: true, //默认为false
				release: true
			}
		});
		//非手机端时，   不加凝视   不加 顶部      反之加加凝视   加 顶部
		if(mui.os.ios || mui.os.android) {
			$('#islogin').show();
			$('.my-pay-btn').hide();
			$('#top-content').css('margin-top', '1.76rem')
		} else {
			$('.top-tool').hide();
		}
		this.init();
		this.time = 0;
		this.data = "";
		this.addFeedback(); //添加留言
		this.info = ""; //存放广告信息
		//		 document.body.addEventListener('touchmove',handler,false);
		document.querySelector('.js_dialog').addEventListener('touchmove', function(event) {
			event.preventDefault();
		}, false);
		ykp.setLocalStorage('avinfo', window.location.search);

		$('.my-pay-btn').click(function() {
			window.location.href = 'wallte'
		})

		$('.get-money-btn').click(function() {
			window.location.href = 'login'
		})

		$('.js_dialog').click(function() {
			$('.get-money').hide();
			$('.js_dialog').hide();
		})

		$('.lb').css('width', $('.content').width() + 'px')
		$('.ye').css('width', $('.content').width() + 'px')

	})

	function showCall() {
		var height = window.screen.height;
		$('#phone').css('top', (height / 2) + 'px');
		window.onresize = function() { //窗口大小改变适配
			$('#phone').css('top', (height / 2) + 'px');
			$('#phone').css('right', 15 + 'px')
			if(mui.os.ios || mui.os.android) {
				$("#phone a").attr('href', 'tel:' + content.tel);
			}
		};

		$('#phone').click(function() {
			if(mui.os.ios || mui.os.android) {

			} else {
				$('.telbox #tel').text($('#phone a').attr('tel'))
				$('.telbox').show();
			}
		})
		$('.close1').click(function() {
			$('.telbox').hide();
		})
	}

	function addFeedback() {
		$('#submit').click(function() {
			var search = window.location.search
			search = search.replace(/\?/, "").split("=")[1];

			var data = ykp.getFormCode({
				el: "#form"
			});
			if(!data) {
				return false;
			}
			ykp.doAjax({
				url: "/api/banner/message_add",
				method: "post",
				data: {
					id: ad_id, //search.split(",")[0]
					name: data.name,
					content: data.content,
					tel: data.tel,
				},
				success: function(res) {
					mui.toast("添加成功");
				}
			})

		})

	}

	//PC直接打开详情 不加 凝视 不显示钱包 pc把链接发送给手机用户 手机用户没有登录状态 不加凝视 不显示我的钱包（ 因为uid为0） 手机用户登录状态下 直接取登录状态下的 uid 获取余额 加凝视 显示我的钱包

	function init() {
		var that = this;
		var search = window.location.search
		search = search.replace(/\?/, "").split("=")[1];
		if(ykp.getLocalStorage('userInfo')) {
			if(!JSON.parse(ykp.getLocalStorage('userInfo')).uid) {
				mui.toast("登录失效，请重新登录")
				ykp.clearLocalStorage();
				setTimeout(function() {
					window.location.href = 'login';
				}, 2000);
			}
		}
		var data = {
			uid: suiyi3,
			ad_id: ad_id, //search.split(",")[1]
			is_login: 1,
			//search.split(",")[2].indexOf('&') != -1 ? search.split(",")[2].slice(0, search.split(",")[2].indexOf('&')) : search.split(",")[2]
			channel: "other",
			un_id: ykp.getLocalStorage('un_id') || 0
		}
		//用户id 不存在时，   不加凝视   不加 顶部      反之加加凝视   加 顶部
		if(ykp.getLocalStorage('userInfo')) {
			if(JSON.parse(ykp.getLocalStorage('userInfo')).uid) {
				data.my_uid = suiyi3
			}
		} else {
			data.my_uid = suiyi3
			if(data.my_uid == 0) {
				$('.top-tool').hide();
				$('#top-content').css('margin-top', '0');
			}
		}
		ykp.doAjax({
			url: "/api/Rules/banner_fx_detail",
			method: "post",
			data: data,
			success: function(res) {
				if(res.code == 400) {
					mui.toast("登录失效，请重新登录");
					return false;
				}
				if(res.code == 300) {
					mui.toast("该广告已下架");
					$('.ruleBtn').remove();
					return false;
				}
				that.look_time = res.data.look_time;

				var content = JSON.parse(res.data.content);
				if(!ykp.getLocalStorage('un_id')) {
					ykp.setLocalStorage('un_id', res.data.un_id);
				}
				that.info = res.data;
				that.getContent(content)
				if(!res.data.earn) {
					$('.top-tool').hide();
					$('#top-content').css('margin-top', '0');
				}
				if(ykp.getLocalStorage('userInfo')) {
					$('#yylb').text(res.data.earn + "LCB");
					$('#user_earn').text(res.data.earn + "LCB")

				} else {
					$('#yylb').text(res.data.lcb + "LCB");
					$('#user_earn').text(res.data.earn + "LCB")
				}
				if(res.data.phoneAlert) {
					that.getAlert(JSON.parse(res.data.phoneAlert))
				}
				if(res.data.phone_number) {
					that.getCall(JSON.parse(res.data.phone_number))
				}
				that.getCall(1)
				$('#onProcess').parent().remove();
				var shareTitle = that.info.fx_name;
				var shareContent = that.info.fx_content;
				var shareImg = that.info.fx_img;
				var shareUrl = that.info.fx_url+",微信 ,wechat,QQ,qq,空间 ,qzone,微博 ,tencentweibo";
				console.log(shareTitle, shareContent, shareImg, shareUrl)
				var isShare = 1;
				if(!mui.os.ios) {
					shareActivity(shareTitle, shareContent, shareImg, shareUrl, isShare); //传给ios端的方法
				} else {
					window.android.shareActivity(shareTitle, shareContent, shareImg, shareUrl, isShare); //传给android端的方法
				}
				
			}
		})
	}

	function getCall(content) {
		var that = this;
		if(content.istel) {
			$("#phone").show().attr('money', content.money).addClass('longtap');
			if(mui.os.ios || mui.os.android) {
				$("#phone a").attr('href', 'tel:' + content.tel);
			} else {
				$("#phone a").attr('tel', content.tel);
			}
			showCall();
		}
	}

	function getAlert(content) {
		var html = "";
		if(content.hasPhoneAlert) {
			//<h3>${content.alert_name}</h3>
			html += `
			<div class="alert-con" style="opacity: 1; ">
					<div class="alert-img-box" >
						<img class="close" src="/resource/front/images/forward/delete.png" />
						<div id="" class="get-money1">
							<a ${content.alert_url_type == 0 ? '' : (content.alert_url_type == 2 ? "href=advInfo?data="+content.alert_next_id : "href="+content.alert_next_id+"")}>
								<img class="lazy" data-original="${content.alert_objUrl_base}"  />
							</a>
						</div>
						
					</div>
			</div>`;
			//src="${content.alert_objUrl_base}"
			$('.js_dialog').show();
			$('.content').append(html);
			document.body.style.overflow = 'hidden';
			setTimeout(function() {
				$('.alert-con').remove();
				$('.js_dialog').hide();
				document.body.style.overflow = 'auto';
			}, content.alert_time * 1000)
			$('.close').click(function() {
				$('.alert-con').remove();
				$('.js_dialog').hide();
				document.body.style.overflow = 'auto';
			})
			$("img.lazy").lazyload({
				effect: "fadeIn"
			});
		}
	}

	function getContent(content) {
		console.log(content)
		var html = "";
		var ly = "";
		var data = [{}];
		var search = window.location.search
		search = search.replace(/\?/, "").split("=")[1];
		var url = "";
		for(var i in content) {
			if(content[i].type == 0) { //单图      1外2内
				html += "<a class='longtap' " + (content[i].url_type != 0 ? (content[i].url_type == 1 ? "href='" + content[i].href : 'href=advInfo?data=' + content[i].href) : '') + "'><img class='lazy' data-original='" + content[i].img_base + "'/></a>";
			} else if(content[i].type == 1) { //标题
				html += `<div  class=" ${content[i].style == 0 ? 'left' : 'right'}" >${content[i].title}</div>`;
			} else if(content[i].type == 2) { //富文本
				html += "<div class='ql-snow' style='font-size: 12px;'><div  money=" + content[i].money + " style='white-space: pre-wrap' class='longtap richText ql-editor' id='texttrea" + i + "' data-key='" + content[i].key + "'  data-type='" + content[i].type + "'>" + content[i].richText + "</div></div>";
			} else if(content[i].type == 3) { //辅助空白
				var div = "<div  style='" + getStyle(content[i].spaceColor) + "'></div>"
				html += div;
			}
			//			else if(content[i].type == 5) { //电话  font-size:0.426666rem;   font-size:0.426666rem;
			//				html += `<div class='longtap' data-key="${content[i].key}"  data-type="${content[i].type}" id=""><p style="width: 100%;height:0.426666rem;line-height: 0.426666rem;margin-top:0.426666rem; margin-bottom: 10px;">拨打下方电话</p>
			//			<div class="" style="height: 0.426666rem;line-height: 0.426666rem; display: flex;align-items: center;">
			//				<a class="tel" style="display: inline-block;margin-left: 0.28rem;" href="tel:${content[i].tel}" tel='${content[i].tel}'>
			//					${content[i].tel}  
			//				</a>
			//				<img class="tel" src="/resource/front/images/forward/call.png" style="width:  0.3rem; height: 0.3rem;margin-left: .11rem;"/>
			//			</div>
			//			
			//		</div>`;
			//			}
			else if(content[i].type == 6) { //留信息
				ly += `<div id="ly" class='longtap' data-type="${content[i].type}" data-key="${content[i].key}">
				<p style="margin-top: .07rem;word-break: break-all; ${getStyle(content[i].fontSize1)}" >${content[i].title}</p>
				<p style="margin-top:.11rem; ${getStyle(content[i].fontSize2)}">${content[i].info}</p>
			</div>`;
			} else if(content[i].type == 7) {
				html += '<img class="lazy" id="qrcode" data-key="' + content[i].key + '" data-type="' + content[i].type + '" style="width:100%;" data-original="' + content[i].img_base + '" />'
			}
		}

		$("#top-content").html(html);
		$("#bottom-content").html(ly);
		$("#top-content img").lazyload({
			effect: "fadeIn"
		});
		setTimeout(function() {
			if(mui.os.ios || mui.os.android) { //手机加 
				this.getScroll(); //添加加币规则
			}
		}, 100)
		if(ly) {
			$('#form').show();
		}
	}

	function getScroll() {
		var that = this;
		var count = 0;
		var clientHeight = document.body.clientHeight;
		var height = window.screen.height;
		var topp = 0;
		if(that.info.earn == null) {
			return false;
		}
		$(window).on('scroll', function() {
			topp = $(document).scrollTop();
		})
		setInterval(function() {
			that.time = that.time + 1;
			if(height + topp > (clientHeight / 2) && !that.data) {
				if(that.time >= that.look_time && count == 0) {
					that.add_ningshi();
					count++;
				}
			}
		}, 1000)

		//当页面高度超过屏幕的2倍时   滚动距离+屏幕高度 大于 总高的2分之1 并且 没有添加金币的时候开启滚动跳监听
		// 反之3秒后执行添加金币
		if(height * 2 <= (height + topp)) {
			setTimeout(function() {
				that.add_ningshi();
			}, that.look_time * 1000);
		}

	}

	function add_ningshi() {
		var search = window.location.search
		search = search.replace(/\?/, "").split("=")[1];
		var that = this;
		ykp.doAjax({
			url: "/api/Rules/xq_add_ningshi",
			method: "post",
			data: {
				uid: suiyi3, //广告用户id
				ad_id: ad_id, //广告id
				channel: "other", //推广方式
				my_uid: suiyi3,
				is_login: ykp.getLocalStorage('userInfo') ? 1 : 2,
				un_id: ykp.getLocalStorage('un_id')
			},
			loading: true,
			success: function(res) {
				if(res.code == 200) {
					$('.get-money').fadeIn(1000);
					$('#lcb').text(that.info.look_money);
					that.money();
					$('#user_earn').text(res.data.lcb + 'LCB')
				}
				$('#yylb').text(res.data.lcb + 'LCB');
			}
		})

	}
	var num = 1;

	function money() {

		var flyer = $('<img class="u-flyer" src="/resource/front/images/forward/money2.png">');
		setTimeout(function() {
			flyer.fly({
				start: {
					left: $('.alert-img-box').width() - 60,
					top: $('.alert-img-box').height() + 80
				},
				end: {
					//document.body.clientWidth - 
					left: 100,
					top: 30,
					width: 0,
					height: 0
				},
				onEnd: function() {
					this.destory();
				}
			});
			if(num < 11) {
				num++;
				money();
			} else {
				$('.get-money').fadeOut(1000);
			}
		}, 100)
	}

	function getStyle(obj) {
		var style = "";
		for(var i in obj) {
			style += (i + ":" + obj[i] + ";");
		}
		return style;
	}
</script>